//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#ifndef TRACTORTRACEREADER_H_
#define TRACTORTRACEREADER_H_

#include <AnalogueModel.h>
#include "traceList.h"
#include <cmath>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <math.h>

using namespace std;

class tractorTraceReader {

public:
    std::string directoryPath;
    std::vector<std::string> fileList;
    std::vector<int> idFileList;
    std::vector<traceList> traces;

public:
    tractorTraceReader(std::string dPath, std::vector<std::string> fList, std::vector<int> idFList):
        fileList(fList),
        idFileList(idFList)
    {
        directoryPath = string(dPath);
        for(unsigned int i=0; i<fileList.size(); i++){
            EV << "reading file: " << directoryPath+fileList[i] <<endl;
            traceList* t = new traceList();
            traces.push_back(*t);
            traces[i].readAndStoreFile(directoryPath+fileList[i]);
        }
    }
    virtual int searchInTraces(int sender, int receiver, simtime_t t_simul);
    virtual double convertSimulTimestamp(simtime_t t_simul, int t_real_first, int t_real_last);
    std::vector<int> indexOfNode(int node);
};

#endif /* TRACTORTRACEREADER_H_ */
